<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="crm.model.Recepit"%>
<%@page import="crm.util.ParamUtil"%>
<%@page import="crm.util.DateTime"%>
<%@page import="crm.model.Employees"%>
<%@page import="crm.control.RecepitControl"%>
<%@page import="crm.control.CustomerControl"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>跟单添加处理</title>
</head>
<body>
<%
      request.setCharacterEncoding("UTF-8");
     Employees cu = (Employees)session.getAttribute("user");
    
     Recepit re = new Recepit();
      re.setTitle(ParamUtil.getString(request,"title",""));
      re.setConsumer_id(ParamUtil.getInt(request,"consumer",0));
      re.setLinkman_id(ParamUtil.getInt(request,"linkman_id",0));
      re.setCreat_time(DateTime.DateTime());
     // re.setCreator("陈勇");
      re.setCreator(cu.getName()); //登陆页面完成后去掉注释
      re.setIntention(ParamUtil.getString(request,"intention","0"));
      re.setSort(ParamUtil.getString(request,"sort","0"));
      re.setStage(ParamUtil.getInt(request,"stage",1));
      re.setPerson1("@"+ParamUtil.getString(request,"person1",String.valueOf(cu.getId()))+"@"+ParamUtil.getInt(request,"stage",1)+"@0@0@");//第一个跟单人开始阶段为填写时阶段
     System.out.print("EEE"+re.getPerson1()+"DDD");
      re.setCurrent_person(ParamUtil.getInt(request,"person1",cu.getId()));   //填写跟单时当前跟单人为第一个跟单人
      
      String predict_amount =ParamUtil.getString(request,"predict_amount","0");
      float p_amount = Float.parseFloat(predict_amount);
      if(ParamUtil.getInt(request,"danwei")==1){
    	  predict_amount = String.valueOf(p_amount*10000);
      }
      re.setPredict_amount(predict_amount+"");
      
      re.setPredict_time(ParamUtil.getString(request,"predict_time",""));
      
      String p1 = ParamUtil.getString(request,"product1","无");
      String p2 = ParamUtil.getString(request,"product2","无");
      String p3 = ParamUtil.getString(request,"product3","无");
      
      re.setPrduct("@"+p1+"@"+p2+"@"+p3+"@");
      re.setPerson2("");re.setPerson3("");
      if(RecepitControl.addRecepit(re)){
         %>
         <script>
         if(window.confirm("添加成功,是否继续添加跟单？")){
               window.top.location.href="recepit_add.jsp"; 
             }else{
         window.top.location.href="show_all_recepits.jsp";}
         </script>
         <%
      }else{
      %>
         <script>
         alert("添加失败");
         history.go(-1);
         </script>s
         <%
      }
      
 %>
</body>
</html>